package com.aboo.frame.constant;

import java.util.HashMap;
import java.util.Map;

public enum ErrEnum {
	
	ERR_000000("000000", "成功"),
	ERR_000001("000001", "系统异常"),
	ERR_000002("000002", "网络存在问题"),
	ERR_000003("000003", "参数缺少或不合法");

	private String value;
	private String text;
	
	private ErrEnum(String value, String text) {
		this.value = value;
		this.text = text;
	}
	
	public static Map<String, String> getMap() {
		Map<String, String> map = new HashMap<>(8);
		ErrEnum[] systemArr = ErrEnum.values();
		for (ErrEnum system : systemArr) {
			map.put(String.valueOf(system.getValue()), system.getText());
		}
		
		return map;
	}
	
	public static String getText(String value) {
		ErrEnum[] systemArr = ErrEnum.values();
		for (ErrEnum system : systemArr) {
			if (value.equals(system.getValue()))
				return system.getText();
		}
		
		return null;
	}
	
	public static ErrEnum getEnum(String value) {
		ErrEnum[] systemArr = ErrEnum.values();
		for (ErrEnum system : systemArr) {
			if (value.equals(system.getValue()))
				return system;
		}
		
		return null;
	}

	public String getValue() {
		return value;
	}

	public String getText() {
		return text;
	}

}
